<?php



namespace App\Http\Requests\Company;


use Illuminate\Support\Facades\Auth;

class PaperRequest extends BaseRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'title' => 'required|max:120',

        ];
    }

    public function messages()
    {
        return [
            'title.required' => __('请输入试题的标题'),
            'thumb.required' => __('请输入试卷的封面'),
            'sale_type.required' => __('请输入试卷售卖类型'),

        ];
    }

    public function filldata()
    {
        $user  = Auth::user();
        return [
            'user_id'=>$user['app_id'],
            'company_id'=>$user['login_company_id'],
            'title' =>(string) $this->input('title', ''),
            'thumb' => $this->input('thumb'),
            'description' => $this->input('description'),
            'type' => (string)$this->input('type', '专项'),
            'rating' => (int)$this->input('rating', 1),
            'difficulty'=>(int)$this->input('difficulty','基础'),
            'charge'=>(float)$this->input('charge',0.00),
            'category_id'=>(int)$this->input('category_id',0),
            'pass_grade'=>(int)$this->input('pass_grade',[]),
            'exam_time'=>(int)$this->input('exam_time',[]),
            'images' => (array)$this->input('images', []),
            'video' => (array)$this->input('video'),
            'sale_type' => (array)$this->input('sale_type'),

        ];
    }
}
